﻿#region Copyright Notice
// This file is part of GestionPedago.
// <description>
// Copyright (C) 2012 ENI Ecole Informatique
// 
// GestionPedago is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// <program> is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
#endregion

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.IO;
using System.Drawing;
using System.Globalization;

namespace GestionPedago.Converters
{
    /// <summary>
    /// Classe ImageConverter
    /// </summary>
    public sealed class ImageConverter : IValueConverter {

        /// <summary>
        /// Renvoi un objet image pour le chemin passé en paramètre
        /// </summary>
        /// <param name="value">chemin vers l'image</param>
        /// <returns>BitmapImage</returns>
        public object Convert(object value, Type targetType,
                              object parameter, CultureInfo culture) {
            try {
                return new BitmapImage(new Uri((string)value, UriKind.RelativeOrAbsolute));
            } catch {
                return new BitmapImage();
            }
        }

        public object ConvertBack(object value, Type targetType,
                                  object parameter, CultureInfo culture) {
            throw new NotImplementedException();
        }
    }

}
